package br.edu.ufabc.gtrnp.helppo.presentation.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import br.edu.ufabc.gtrnp.helppo.business.InventarioBusiness;
import br.edu.ufabc.gtrnp.helppo.persistence.entity.Usuario;
import br.edu.ufabc.gtrnp.helppo.presentation.controller.InventarioUsuarioForm;
import br.edu.ufabc.gtrnp.helppo.util.HelppoConstants;

/**
 * @struts.action name="inventarioUsuarioForm" path="/inventarioUsuario"
 *                scope="request" parameter="action" validate="false"
 * 
 * @struts.action-forward name="inventarioUsuario"
 *                        path="/jsp/inventarioUsuario.jsp"
 * 
 */
public class InventarioUsuarioAction extends DispatchAction {

	@Override
	protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		InventarioUsuarioForm frm = (InventarioUsuarioForm) form;
		Usuario usuario = (Usuario) request.getSession().getAttribute(
				HelppoConstants.USUARIO_LOGADO);
		
		frm.setItensInventario(InventarioBusiness.getInstance().recuperaItensInventario(usuario));

		return mapping.findForward("inventarioUsuario");
	}

}
